/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * <p>Project: javase2203 - Reflection2
 * <p>Powered by webrx On 2022-08-11 11:43:33
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
@SuppressWarnings("all")
public class Reflection2 {
    public static void main(String[] args) throws Exception {
        //正射
        System.out.println(new String("hello world").toUpperCase());

        //反射实现实例化类，调用方法
        Class s = String.class;
        Constructor con = s.getConstructor(String.class);
        Object ss = con.newInstance("hello world");
        Method m = s.getMethod("toUpperCase");
        System.out.println(m.invoke(ss));
    }
}
